package com.nbsaas.boot.order.rest.convert;

import com.nbsaas.boot.order.data.entity.OrderItem;
import com.nbsaas.boot.order.api.domain.response.OrderItemResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;
/**
* -实体对象转化成响应对象
*/

public class OrderItemResponseConvert  implements Converter<OrderItemResponse,OrderItem> {

    @Override
    public OrderItemResponse convert(OrderItem source) {
        OrderItemResponse  result = new  OrderItemResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getSkuType()!=null){
                    Map<Integer,String> SkuTypeMap=new HashMap<>();
                        SkuTypeMap.put(1,"商品");
                        SkuTypeMap.put(2,"sku");
                    String label=  SkuTypeMap.get(source.getSkuType());
                    result.setSkuTypeName(label);
                    }
                    result.setSkuType(source.getSkuType());
                    if(source.getOrder()!=null){
                        result.setOrder(source.getOrder().getId());
                    }
        return result;
    }

}

